﻿@using Coleotrack.Models.Setup
@using Coleotrack.Resources
@model DatabaseViewModel

@{
    ViewBag.Title = "Welcome";
    Layout = "~/Views/Setup/_Site.cshtml";
}

<h3>Database</h3>
@using(Html.BeginForm()) {
<div class="database-settings">
    <p>Please provide your connection settings to your Microsoft SQL Server (includes Express edition).</p>
    @Html.ValidationSummary(false, labels.ErrorsOccured)
    
    <div class="required">@Html.LabelFor(x => x.Host)</div>
    <div>@Html.TextBoxFor(x => x.Host)</div>

    <br />
    
    <div class="auth-type">
        <div>@Html.RadioButtonFor(x => x.IntegratedAuth, true, new {id="windows"}) <label for="windows">Windows-Authentifizierung</label></div>
        <div>@Html.RadioButtonFor(x => x.IntegratedAuth, false, new {id="sqlserver"}) <label for="sqlserver">SQL-Server-Authentifizierung</label></div>
    </div>

    <div class="sqlserver-auth">
        <div class="required">@Html.LabelFor(x => x.Username)</div>
        <div>@Html.TextBoxFor(x => x.Username)</div>
        <div class="required">@Html.LabelFor(x => x.Password)</div>
        <div>@Html.PasswordFor(x => x.Password)</div>
    </div>

    <br />
    <div class="required">@Html.LabelFor(x => x.Database)</div>
    <div>@Html.TextBoxFor(x => x.Database)</div>
</div>

<div class="commands">
    <div class="prev">@Html.ActionLink("prev", "Index", "Setup")</div>
    <div class="next"><input type="submit" value="next" /></div>
</div>

}

@section Menu {
    @Html.Partial("_Menu", 2)
}

@section Head {
    <script type="text/javascript">
        $(document).ready(function () {
            $(".auth-type").change(function () {

                var value = $('input[name="IntegratedAuth"]:checked').val();
                
                if (value == "True") {
                    $('.sqlserver-auth input').attr('disabled', true);
                }
                else {
                    $('.sqlserver-auth input').removeAttr('disabled');
                }
            });
        });
    </script>
}